"""
Case Type   : datakit安装
Case Name   : 超级管理员账号密码登录
Create At   : 2025/4/21
Owner       : @lonely-dance
Description :
    1.超级管理员账号密码登录
Expect      :
    1.成功
History     :
"""

import os
import unittest

from yat.test import Node
from yat.test import macro
from testcase.utils.Logger import Logger
from testcase.utils.CommonSH import CommonSH
from testcase.utils.datakit_api.CommonApi import CommonApi


class Tools(unittest.TestCase):
    def setUp(self):
        self.log = Logger()
        self.log.info(f"-----{os.path.basename(__file__)} start-----")
        self.com_sh = CommonSH()

    def test_base_ops(self):
        text = '----step1:超级管理员账号密码登录 expect:成功----'
        self.log.info(text)
        encrypt_password = self.com_sh.encrypt_password(f'{macro.DATAKIT_PASSWD}')
        response = self.com_sh.user_login(encrypt_password, user='admin')
        self.log.info(response.json())
        self.assertEqual('success', response.json()['msg'], '执行失败' + text)

    def tearDown(self):
        self.log.info('----无需清理环境----')
        self.log.info(f"-----{os.path.basename(__file__)} finsh-----")
